

/* 先插入数据 */
function getStudentOverview() {

    axios.get('/student/overview')
        .then(result => {
            // 解构
            const { avgAge, avgSalary, proportion, total } = result.data.data
            //把值放在上面
            document.querySelector('.total').innerHTML = total
            document.querySelector('.avgAge').innerHTML = avgAge
            document.querySelector('.avgSalary').innerHTML = avgSalary
            document.querySelector('.proportion').innerHTML = proportion




        })
}

getStudentOverview()


function salaryLine() {
    axios.get('/student/list')
        .then(result => {
            //console.log(result);
            const list = result.data.data
            console.log(list);
            const salarys = list.map(v => v.salary)
            const truesalarys = list.map(v => v.truesalary)
            const names = list.map(v => v.name)

            const myChart = echarts.init(document.querySelector('.line'));
            const option = {
                title: {
                    text: '薪资 Salary'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {},

                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: names
                },
                yAxis: {
                    type: 'value',

                },
                dataZoom: [
                    {
                        type: 'inside',
                        start: 0,
                        end: 50
                    },
                    {
                        start: 0,
                        end: 50           //总共为100份 这里占了50份 
                    }
                ],
                series: [
                    {
                        name: '期待薪资',
                        type: 'line',
                        smooth: true,//丝滑线
                        symbol: 'circle',//圆点实心
                        data: salarys,

                    },
                    {
                        name: '实际薪资',
                        type: 'line',
                        smooth: true,
                        symbol: 'circle',
                        data: truesalarys,

                    }
                ]
            }

            myChart.setOption(option);



        })
}

salaryLine() 